<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>lic</title>
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/login.min.css" th:href="@{/css/login.min.css}" rel="stylesheet"/>
    <!-- 360浏览器急速模式 -->
    <meta name="renderer" content="webkit">
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/>
    <style type="text/css">
        label.error { position:inherit;  }
        .signinpanel {
            color: #1a2226;
        }
    </style>
    <script>
        if(window.top!==window.self){alert('未登录或登录超时。请重新登录');window.top.location=window.location};
    </script>
</head>
<body class="signin">
    <div class="signinpanel">
        <div class="row">

            <div class="col-sm-6">
                <form id="signupForm" autocomplete="off" method="post">
                    <h4 class="no-margins">机器信息：</h4>
                    <p class="m-t-md"></p>
                    <input type="text" name="upwd" class="form-control upwd"  placeholder="口  令" value="" />
                    <input type="text" name="seCodeNum" class="form-control seCodeNum"  placeholder="机器码" value="" />

                    <button class="btn btn-success btn-block" id="btnSubmit" data-loading="正在提交，请稍候...">生成</button>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left" id="sn_here">
                 Copyright © 2021-2024  All Rights Reserved. <br>
            </div>
        </div>
    </div>
    <script th:inline="javascript"> var ctx = [[@{/}]]; </script>
<!-- 全局js -->
    <script src="../static/jquery.min.js" th:src="@{/jquery.min.js}"></script>
    <script src="../static/validate/jquery.validate.min.js" th:src="@{/validate/jquery.validate.min.js}"></script>
    <script src="../static/layer/layer.min.js" th:src="@{/layer/layer.min.js}"></script>

    <script>

    $(function() {
        validateRule();

    });

    $.validator.setDefaults({
        submitHandler: function() {
            login();
        }
    });

    function login() {
        var upwd = trim($("input[name='upwd']").val());
        var seCodeNum = trim($("input[name='seCodeNum']").val());
        $.ajax({
            type: "post",
            url: "/generatesn",
            data: {
                "upwd": upwd,
                "seCodeNum": seCodeNum
            },
            success: function(r) {
                // $(".form-control").val("");
                $("#sn_here").text(r);
            }
        });
        // 空格截取
        function trim(value) {
            if (value == null) {
                return "";
            }
            return value.toString().replace(/(^\s*)|(\s*$)|\r|\n/g, "");
        }
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                upwd: {
                    required: true
                },
                seCodeNum: {
                    required: true
                }
            },
            messages: {
                upwd: {
                    required: icon + "请输入用户名",
                },
                seCodeNum: {
                    required: icon + "请输入机器码",
                }
            }
        })
    }

    function getParam(paramName) {
        var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }
    /** 消息状态码 */
    web_status = {
        SUCCESS: 0,
        FAIL: 500,
        WARNING: 301
    };
</script>
</body>
</html>
